<?php $autos = isset($autos) ? $autos :array();?>
<div class='container-fluid'>
<?php echo View::make('share.backend_nav')->with('nav', Config::get('app.nav.product.sub'));?>
<div class='board'>
  <div class='search' style='height:120px;min-height:120px;border:3px solid #ddd;'>
    <div class='header'>
      <p>筛选条件</p>
    </div>
    <div class='condition'>
      <form style='margin-left:10px;margin-top:10px;' method='get' id='search_form'>
      <div class="control-group">
      <label for='category_id'>商品类型</label>
      <select name='category_id'>
        <option value='0'>全部</option>
	<?php $cates = Category::all();?>
      <?php $category_id = intval(Input::get('category_id', 0));?>
	<?php foreach ($cates as $c):?>
	<option value='<?php echo $c->id;?>' <?php if ($c->id == $category_id) echo "selected='selected'";?>><?php echo $c->cname;?></option>
	<?php endforeach;?>
      </select>
      </div>

      <div class="control-group">
      <label for='mall'>商品来源</label>
      <select name='mall'>
        <option value=''>全部</option>
	<?php $mall = Config::get('app.mall');?>
        <?php $c_mall = Input::get('mall', '');?>
	<?php foreach ($mall as $m):?>
	<option value='<?php echo $m['ename'];?>' <?php if ($m['ename'] == $c_mall) echo "selected='selected'";?>><?php echo $m['cname'];?></option>
	<?php endforeach;?>
      </select>
      </div>

      <div class="control-group">
        <button type='submit' class='btn btn-success' style='margin-top:25px;'>搜索</button>
      </div>
      </form>
    </div>
  </div>
<div style='height:10px;'></div>
<span class='label label-info'>自动添加设置</span>
<table class='table table-bordered table-striped'>
  <thead>
    <tr>
      <th style='width:80px;'>#ID</th>
      <th style='width:100px;'>#Mall</th>
      <th style='width:100px;'>#Category</th>
      <th style='width:300px;'>#Tag</th>
      <th>#Detail</th>
      <th style='width:40px;'>#OP</th>
    </tr>
  </thead>
  <tbody>
  <?php foreach ($autos as $a):?>
    <tr>
      <td><?php echo $a->id;?></td>
      <td><?php echo $a->mall;?></td>
      <td>
        <?php $c = Category::find($a->category_id); if ($c) echo $c->cname;?>
      </td>
      <td><?php echo $a->tag;?></td>
      <td>
        <?php echo View::make('product.auto.taobao_detail')->with('detail', $a->detail);?>
      </td>
      <td><a href='javascript:void(0)' data-id='<?php echo $a->id?>' class='btn btn-danger btn-mini delete'>删除</a></td>
    </tr>
  <?php endforeach;?>
  </tbody>
</table>
<div class="pagination pull-right">
  <ul><?php echo $page;?></ul>
</div>
</div>
</div>
